import React, { Component } from 'react'
import { IWidgetProps } from '../Widget'
import Table from './Table'
import ComponentTypes from '../../config/component/ComponentTypes'
import Assembly  from'./assembly'
import RollingPlate from'./rollingPlate'

export interface IChartProps extends IWidgetProps {
  width: number
  height: number
}

export class CombinedChart extends Component<IChartProps, {}> {
  public shouldComponentUpdate(nextProps: IChartProps) {
    return nextProps.renderType !== 'loading'
  }
  public render() {
    const { selectedChart } = this.props
    switch (selectedChart) {
      case ComponentTypes.Table:
        return (
          <Table {...this.props} />
        )
      case ComponentTypes.Carousel:
        return (
          <Assembly {...this.props} />
        )
      case ComponentTypes.RollingPlate:
        return (
          <RollingPlate {...this.props} />
        )
      default:
        return (
          <Table {...this.props} />
        )
    }
  }
}

export default CombinedChart
